package com.forecasting.unittest;

import static org.junit.Assert.*;

import org.junit.Test;

import com.forecasting.utility.Utility;

public class UtilityTest {
	
	
	public void initialValue(){
		
	}
	
	@Test
	public void testGetFactorial() {
		int f0 = 0;
		int f1 = 1;
		int f2 = 2;
		int f3 = 3;
		int f4 = 4;
		
		assertTrue(Utility.getFactorial(f0) == 1);
		assertTrue(Utility.getFactorial(f1) == 1);
		assertTrue(Utility.getFactorial(f2) == 2);
		assertTrue(Utility.getFactorial(f3) == 6);
		assertTrue(Utility.getFactorial(f4) == 24);
		//verify if it is double 
		
	}

	@Test
	public void testFormatDecimal() {
		double d = 1.9876543;
		assertTrue(Utility.formatDecimal(d, 0) == 2.0);
		assertTrue(Utility.formatDecimal(d, 1) == 2.0);
		assertTrue(Utility.formatDecimal(d, 2) == 1.99);
		assertTrue(Utility.formatDecimal(d, 3) == 1.988);
		assertTrue(Utility.formatDecimal(d, 4) == 1.9877);
		assertTrue(Utility.formatDecimal(d, 5) == 1.98765);
		assertTrue(Utility.formatDecimal(d, 6) == 1.987654);
		assertTrue(Utility.formatDecimal(d, 7) == 1.9876543);
		assertTrue(Utility.formatDecimal(d, 8) == 1.98765430);
		
		assertTrue(Utility.formatDecimal(1.43, 0) == 1.0);
		assertTrue(Utility.formatDecimal(1.43, 1) == 1.4);
		
	}

}
